package com.sk.gzwater.adapter;

import java.text.DecimalFormat;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.SeriesSelection;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
import org.achartengine.renderer.XYMultipleSeriesRenderer;
import org.achartengine.renderer.XYSeriesRenderer;

import com.sk.gzewop.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.graphics.Paint.Align;
import android.view.View;
import android.view.View.OnClickListener;

public abstract class LineCharts {
	public GraphicalView chartView;
	public DecimalFormat df = new DecimalFormat("0.#");
	public GraphicalView getLineChart(Context context,XYMultipleSeriesDataset seriesDataset,XYMultipleSeriesRenderer seriesRenderer) {
		chartView = ChartFactory.getLineChartView(context, seriesDataset, seriesRenderer);
		return chartView;
	}
	public XYMultipleSeriesRenderer setSeriesRenderer(String chartName,String YName){		
		XYMultipleSeriesRenderer seriesRenderer = new XYMultipleSeriesRenderer();
		seriesRenderer.setApplyBackgroundColor(true);
		seriesRenderer.setBackgroundColor(Color.rgb(255,255,255));
		seriesRenderer.setAxesColor(Color.BLACK);
		seriesRenderer.setMarginsColor(Color.rgb(255,255,255));
		seriesRenderer.setLabelsColor(Color.BLACK);
		seriesRenderer.setXLabelsColor(Color.BLACK);
		seriesRenderer.setYLabelsColor(0, Color.BLACK);
//		seriesRenderer.setGridColor(0x7f050000);
		seriesRenderer.setAxisTitleTextSize(16);
		seriesRenderer.setChartTitleTextSize(20);
		seriesRenderer.setLabelsTextSize(15);
		seriesRenderer.setLegendTextSize(15);
		seriesRenderer.setYLabelsAlign(Align.RIGHT);	
//		seriesRenderer.setShowGridX(true);
		seriesRenderer.setInScroll(true);
		seriesRenderer.setXLabels(0);
		seriesRenderer.setYAxisMin(0);
		seriesRenderer.setZoomButtonsVisible(true);		
		seriesRenderer.setMargins(new int[]{30,40,10,30});		
		seriesRenderer.setPointSize(10);
		seriesRenderer.setChartTitle(chartName);
		seriesRenderer.setYTitle(YName);
		seriesRenderer.setClickEnabled(true);
		seriesRenderer.setSelectableBuffer(30);
		seriesRenderer.setFitLegend(true);
//		seriesRenderer.setDisplayChartValues(true);
		seriesRenderer.setPanEnabled(true);
		seriesRenderer.setPanEnabled(true, false);		
//		seriesRenderer.setPanLimits(new double[] {-4.0, 4.0,0, 0});
		seriesRenderer.setExternalZoomEnabled(true);
		seriesRenderer.setZoomEnabled(true);
		seriesRenderer.setZoomEnabled(true, false);
//		seriesRenderer.setZoomLimits(new double[]{-4, 4,0, 0});

		return seriesRenderer;
	}
	public XYMultipleSeriesDataset setSeriesDataset(){
		XYMultipleSeriesDataset seriesDataset = new XYMultipleSeriesDataset();
		return seriesDataset;
	}
	public XYSeries setSeries(String title){
		XYSeries currentSeries = new XYSeries(title);
		return currentSeries;
	}
	public XYSeriesRenderer setRenderer(){
		XYSeriesRenderer currentRenderer = new XYSeriesRenderer();
		return currentRenderer;
	}
	public abstract void setShowDetail(boolean arg0,final Context context);
}
